package com.ljkj.blockpay.presenter;

import android.content.Context;

import androidx.annotation.NonNull;

import com.kongzue.baseokhttp.HttpRequest;
import com.kongzue.baseokhttp.listener.JsonResponseListener;
import com.kongzue.baseokhttp.util.JsonList;
import com.kongzue.baseokhttp.util.JsonMap;
import com.kongzue.baseokhttp.util.Parameter;
import com.ljkj.blockpay.basedata.BasePresenter;
import com.ljkj.blockpay.basedata.BasePresenterImpl;
import com.ljkj.blockpay.basedata.BaseView;
import com.ljkj.blockpay.network.ApiToCConfig;

/**
 * Created by yp on 2022/3/9
 */
public class MMAddressPresenter extends BasePresenterImpl<AddressInter.AddressInterView> implements AddressInter.AddressInterPresenterView, BasePresenter {

    public MMAddressPresenter(@NonNull Context context, @NonNull AddressInter.AddressInterView view) {
        super(context, view);
    }

    @Override
    public void deleteaddress(Integer id) {

    }

    @Override
    public void searchaddress() {
        HttpRequest.GET(getContext(), ApiToCConfig.USER_ADDRESS_LIST,
                new Parameter(),
                new JsonResponseListener() {
            @Override
            public void onResponse(JsonMap main, Exception error) {
                if (main.getInt("code") == 0){
                    JsonList jsonList = new JsonList("data");
                    getView().searchSuccess(jsonList);
                }
            }
        });

    }
}
